<?php

/*
 * This page generates the WooCommerce product pricelist
 */
?>


<style>
	ul.pricelistdocuments { list-style:none;padding:0px;margin:0px; }
		ul.pricelistdocuments li { display:inline-block;float:left;margin:0px;margin-right:10px; }
		
	a.producttitle { color:#263692; }
		a.producttitle:hover { color:#747170; }
	
	p.product, p.woocommerce { border:0px !important;padding:16px !important; }
		p.product a, p.woocommerce a { clear:both; }
		p.product del, p.woocommerce del { font-size:15px;font-weight:bold;color:#ff0000;margin-right:10px; }
		p.product ins, p.woocommerce ins { font-size:15px;font-weight:bold;color:#002d55;margin-right:10px;text-decoration:none; }
		#content span.amount { font-size:15px;font-weight:bold; }
		
	input#filter { width:200px;height:30px;line-height:30px; }
</style>

<div style="padding:20px;float:left;margin:0px;margin-bottom:10px;color:#000000;background:#f2f2f2;border-bottom:#747170 1px solid;">
<div style="width:600px;float:left;margin:0px;">
<p><strong>Looking For Something Specific?</strong> Just start typing the SKU / ID / Name of the product that you are looking for below and our table will filter it out of the list for you!</p>
<p>Here are a few keywords to get you started.  If you are look for any of these, enter these keywords in the search box to the right:</p>

<table width="300px" cellpadding="0" cellspacing="0">
    <tr>
        <td>Solar Fountains &amp; Pumps</td>
        <td>aquajet</td>
    </tr>
    <tr>
        <td>Educational Kits</td>
        <td>edusol</td>
    </tr>
    <tr>
        <td>Landscape &amp; Garden Lights</td>
        <td>patiopal</td>
    </tr>
    <tr>
        <td>Commercial Sign Lights</td>
        <td>genlight</td>
    </tr>
    <tr>
        <td>Real Estate Sign Lights</td>
        <td>sunpal</td>
    </tr>
    <tr>
        <td>Billboard Lights</td>
        <td>envirolight</td>
    </tr>
    <tr>
        <td>Solar Cells</td>
        <td>pmaxx</td>
    </tr>
    <tr>
        <td>Solar Panels</td>
        <td>gridmaxx | solmaxx | flexfold</td>
    </tr>
    <tr>
        <td>Complete Power Systems</td>
        <td>trupower</td>
    </tr>
    <tr>
        <td>Battery Chargers</td>
        <td>autosol | isol | travelsol</td>
    </tr>
</table>
</div>

<div style="width:250px;float:right;margin:0px;text-align:right;">
<form id="filter-form">
	<input type="text" name="filter" id="filter" placeholder="Type to search" />
</form>
</div>

</div>

<table class="pricelisttable" width="100%" cellpadding="0" cellspacing="0" border="0">
	<thead>
	<tr>
    	<th style="height:40px;line-height:40px;background:#263692;color:#ffffff;"></th>
        <th style="height:40px;line-height:40px;background:#263692;color:#ffffff;"></th>
        <th style="height:40px;line-height:40px;background:#263692;color:#ffffff;text-align:center;font-size:15px;font-weight:bold;">Savings</th>
    	<th style="height:40px;line-height:40px;background:#263692;color:#ffffff;text-align:center;font-size:15px;font-weight:bold;">Pricing &amp; Add To Cart</th>
    </tr>
    </thead>
    <tbody>
<?php
$args = array('post_type' => 'product', 'posts_per_page' => '-1');
   $pricelist = new WP_Query($args);

   if($pricelist->have_posts()) : 
      while($pricelist->have_posts()) : 
         $pricelist->the_post(); ?>
         
         <?php
		 	$productid = get_the_ID();
			$productsku = get_post_meta($post->ID, '_sku', true);
			$productimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail');
			$listprice = get_post_meta($post->ID, '_regular_price', true);
			$youpayprice = get_post_meta($post->ID, '_sale_price', true);
			$savings = (($listprice - $youpayprice) / $listprice);
			$savings = $savings * 100;
		 ?>
		 
		<tr style="display:table-row;">
                    <td style="width:80px;padding-top:10px;padding-bottom:10px;border-bottom:#cccccc 1px solid;margin:0px;padding-left:10px;padding-right:10px;">
                        <?php if (get_field('productFeaturedImage') != '') { ?>
                            <a href="<?php the_field('productFeaturedImage'); ?>" rel="lightbox" title="<?php the_title(); ?> | View Larger Image">
                                <img src="<?php the_field('productFeaturedImage'); ?>" alt="The Product Image" width="80" height="80" />
                            </a>
                        <?php } else { ?>
                            <a href="<?php echo $productimage[0]; ?>" rel="lightbox" title="<?php the_title(); ?> | View Larger Image">
                                <img src="<?php echo $productimage[0]; ?>" alt="The Product Image" width="80" height="80" />
                            </a>
                        <?php } ?>
                    </td>
            <td style="vertical-align:top;padding-top:10px;padding-bottom:10px;border-bottom:#cccccc 1px solid;margin:0px;">
            	<a class="producttitle" href="<?php the_permalink(); ?>" style="font-size:15px;font-weight:bold;text-decoration:none;margin-bottom:5px;"><?php the_title(); ?></a>
            	<p style="margin:0px;"><span style="font-style:italic;color:#717470;">SKU: <?php echo $productsku; ?></span> | <span style="font-style:italic;color:#717470;">ID: <?php echo $productid; ?></span> | <a href="<?php the_permalink(); ?>" target="_blank">View Product Details</a>
					<?php get_currentuserinfo() ;
						global $user_level;
							if ($user_level = 10) { ?><a href="/../wp-admin/post.php?post=<?php echo $productid; ?>&action=edit" style="font-style:italic;" target="_blank">(Edit Product)</a><?php } ?></p>
            	<ul class="pricelistdocuments" style="margin-top:10px;">
                	<?php
						$args = array('post_type' => 'document', 'meta_key' => 'documentproduct', 'meta_value' => ''.$productid.'');
						$pricelistdocs = new WP_Query($args);

						if($pricelistdocs->have_posts()) : 
							while($pricelistdocs->have_posts()) : 
								$pricelistdocs->the_post(); ?>
                                	<?php if(get_field('documenttype') == 'General Document') { ?>
                                		<li><a href="<?php the_permalink(); ?>" target="_blank" title="Download Document"><img src="/../wp-content/themes/woostore/images/doc-icon-document.jpg" alt="Download The Document" style="width:30px;height:30px;" /></a></li>
                                    <?php } ?>
                                	<?php if(get_field('documenttype') == 'Brochure') { ?>
                                		<li><a href="<?php the_permalink(); ?>" target="_blank" title="Download Brochure"><img src="/../wp-content/themes/woostore/images/doc-icon-brochure.jpg" alt="Download The Brochure" style="width:30px;height:30px;" /></a></li>
                                    <?php } ?>
                                	<?php if(get_field('documenttype') == 'Datasheet') { ?>
                                		<li><a href="<?php the_permalink(); ?>" target="_blank" title="Download Data Sheet"><img src="/../wp-content/themes/woostore/images/doc-icon-data-sheet.jpg" alt="Download The Data Sheet" style="width:30px;height:30px;" /></a></li>
                                    <?php } ?>
                                    <?php if(get_field('documenttype') == 'Installation Manual') { ?>
                                		<li><a href="<?php the_permalink(); ?>" target="_blank" title="Download Installation Manual"><img src="/../wp-content/themes/woostore/images/doc-icon-installation-manual.jpg" alt="Download The Installation Manual" style="width:30px;height:30px;" /></a></li>
                                    <?php } ?>
                                    <?php if(get_field('documenttype') == 'SRCC OG-100 Certification') { ?>
                                		<li><a href="<?php the_permalink(); ?>" target="_blank" title="Download The SRCC OG-100 Certification"><img src="/../wp-content/themes/woostore/images/doc-icon-srcc-og-100.jpg" alt="Download The SRCC OG-100 Certification" style="width:30px;height:30px;" /></a></li>
                                    <?php } ?>
                                    <?php if(get_field('documenttype') == 'SRCC OG-300 Certification') { ?>
                                		<li><a href="<?php the_permalink(); ?>" target="_blank" title="Download The SRCC OG-300 Certification"><img src="/../wp-content/themes/woostore/images/doc-icon-srcc-og-300.jpg" alt="Download The SRCC OG-300 Certification" style="width:30px;height:30px;" /></a></li>
                                    <?php } ?>
                                    <?php if(get_field('documenttype') == 'Certification') { ?>
                                		<li><a href="<?php the_permalink(); ?>" target="_blank" title="Download The Certification"><img src="/../wp-content/themes/woostore/images/doc-icon-certification.jpg" alt="Download The Certification" style="width:30px;height:30px;" /></a></li>
                                    <?php } ?>
                        	<?php endwhile; ?>
                        <?php endif; ?>
                </ul>
            </td>
            <td style="padding-top:10px;padding-bottom:10px;border-bottom:#cccccc 1px solid;margin:0px;text-align:center;font-size:18px;font-weight:bold;color:#263692;">
            	<?php echo round($savings,0) ; ?>%
            </td>
            <td style="vertical-align:top;padding-top:10px;padding-bottom:10px;border-bottom:#cccccc 1px solid;margin:0px;text-align:center;">
            	<?php echo do_shortcode('[add_to_cart id="'.$productid.'" sku="'.$productsku.'"]'); ?>
            </td>
		</tr>
         
<?php endwhile; ?>
<?php endif; ?>
	</tbody>
</table>